# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

from jms.dm.dm_shipno_weight_summary_new_dt import jms_dm__dm_shipno_weight_summary_new_dt
from jms.dm.dm_shipno_change_detail_new import jms_dm__dm_shipno_change_detail_new

jms_dm__dm_shipno_weight_month_summary_new_mt = SparkSqlOperator(
    task_id='jms_dm__dm_shipno_weight_month_summary_new_mt',
    email=['jarl.huang@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    name='jms_dm__dm_shipno_weight_month_summary_new_mt_{{ execution_date | date_add(1) | cst_ds }}',
    email_on_retry=True,
    retries=1,
    sql='jms/dm/dm_shipno_weight_month_summary_new_mt/execute.sql',
    yarn_queue='pro',
    driver_memory='3G' , 
    driver_cores=2 , 
    executor_memory='3G' , 
    executor_cores=2 , 
    pool_slots=2,
    pool='unlimited_pool',
    num_executors=2 , 
    conf={
        'spark.executor.memoryOverhead'             : '2G' , 
          'spark.dynamicAllocation.enabled': 'true',
          'spark.shuffle.service.enabled': 'true',
        'spark.dynamicAllocation.maxExecutors'             : 2 , 
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
          'spark.dynamicallocation.enabled': 'true',
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 120,
          'spark.sql.shuffle.partitions': 200,
          'spark.port.maxRetries': 100
          },
    # hiveconf={'hive.exec.dynamic.partition': 'true',
    #           'hive.exec.dynamic.partition.mode': 'nonstrict',
    #           'hive.exec.max.dynamic.partitions.pernode': 5000,
    #           'hive.exec.max.dynamic.partitions': 30000
    #           },
    execution_timeout=timedelta(hours=1),
    priority_weight=20,
)

jms_dm__dm_shipno_weight_month_summary_new_mt << [
    jms_dm__dm_shipno_weight_summary_new_dt,
    jms_dm__dm_shipno_change_detail_new
]
